<template>
	<div class="page">
		<el-pagination 
		background 
		small 
		layout="prev, pager, next" 
		style="background-color: transparent;"
		:current-page="currentPage[0]"
		:page-size="pageSize[0]"
		:total="total[0]"
		@current-change="changeCurrentPage"
		>
		</el-pagination>
	</div>
</template>
<script>
export default {
	data() {
		return {
			currentPage: this.$store.state.netLogStore.currentPage,			//当前页数
			pageSize: this.$store.state.netLogStore.pageSize,			//一页显示的条目数
			total: this.$store.state.netLogStore.total,				//总条目数
		}
	},
	methods: {
		changeCurrentPage(val) {			//改变当前页数
			let status = this.$store.state.netLogStore.status;
			if(status[0] == 0) {
				this.$store.dispatch('netLogStore/getTableData', val);
			} else if(status[0] == 1) {
				let searchResult = this.$store.state.netLogStore.searchResult,
					startPage = (val * this.pageSize) - this.pageSize,
					endPage = val * this.pageSize;
				let newArr = searchResult.slice(startPage, endPage);
				this.$store.commit('netLogStore/updateTableData', newArr);
			}
			this.$store.commit('netLogStore/updateCurrentPage', val);
		}
	}
}
</script>
<style scoped>
	.page {margin-top: 20px;text-align: center;}
</style>